package com.chang.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.chang.common.validator.ListValue;
import com.chang.common.validator.group.AddGroup;
import com.chang.common.validator.group.UpdateGroup;
import com.chang.common.validator.group.UpdateStatusGroup;
import jakarta.validation.constraints.*;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import java.io.Serializable;

/**
 * 品牌
 * 
 * @author chang
 * @email 2045807586@qq.com
 * @date 2024-01-02 16:10:53
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 */
	@NotNull(message = "修改必须指定id", groups = {UpdateGroup.class}) //分组校验,针对不同操作组来进行单独校验
	@Null(message = "新增不能指定id", groups = {AddGroup.class})
	@TableId
	private Long brandId;
	/**
	 * 品牌名
	 */
	@NotBlank(message = "品牌名不能为空", groups = {AddGroup.class, UpdateGroup.class}) // 不能为空,"" 以及" "空格
	private String name;
	/**
	 * 品牌logo地址
	 */
	@URL(message = "logo必须为一个合法的url地址", groups = {AddGroup.class, UpdateGroup.class})
	@NotBlank(message = "logo地址不能为空", groups = {AddGroup.class})
	private String logo;
	/**
	 * 介绍
	 */
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@NotNull(groups = {AddGroup.class, UpdateGroup.class})
	@ListValue(value = {0, 1}, groups = {AddGroup.class, UpdateStatusGroup.class})
	private Integer showStatus;
	/**
	 * 检索首字母
	 */
	@NotEmpty(groups = {AddGroup.class})
	@Pattern(regexp = "^[a-zA-Z]$", message = "检索首字母必须为单个字母")
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(groups = {AddGroup.class})
	@Min(value = 0, message = "排序必须大于等于0", groups = {AddGroup.class, UpdateGroup.class})
	@Max(value = 100, message = "排序必须小于1000", groups = {AddGroup.class, UpdateGroup.class})
	private Integer sort;

}
